import { getRealityById } from '@/apis/realityScene'
export default {
  data() {
    return {
      id: this.$route.params.id || '',
      ADS_STATIC_PATH: `${process.env.VUE_APP_ADS_STATIC}`,
      detail: {}
    }
  },
  created() {
    this.getDetail()
  },
  methods: {
    getDetail() {
      if (!this.id) {
        this.detail = {}
        return
      }
      getRealityById(this.id).then(res => {
        this.detail = res.data || ''
      })
    },
    downLoad({ fileUrl, fileName }) {
      const arrTmp = fileUrl.split('.')
      const suffix = arrTmp.length > 1 ? arrTmp[arrTmp.length - 1] : ''
      const url = this.$formatURL(fileUrl, this.ADS_STATIC_PATH)
      const name = `${fileName || new Date().getTime()}.${suffix}`
      const params = { downloadURL: url, fileName: name }
      this.$nativeHandler('downloadFiels', params).then(res => {
        this.$toast.success('下载成功')
      }).catch(() => {
        this.$toast.fail('下载失败')
      })
    }
  }

}
